#include "stdafx.h"
#include "pyhgeCore.h"
#include "pyhgeInputEvent.h"
#include "pyhgeVertex.h"
PyObject * pyFRAMEFUNC = NULL;
PyObject * pyRENDERFUNC = NULL;
PyObject * pyGFXRESTOREFUNC = NULL;
PyObject * pyFOCUSLOSTFUNC = NULL;
PyObject * pyFOCUSGAINFUNC = NULL;
PyObject * pyEXITFUNC = NULL;

const char * DESC_HTEXTURE = "HTEXTURE";
const char * DESC_HTARGET = "HTARGET";
const char * DESC_HEFFECT = "HEFFECT";
const char * DESC_HCHANNEL = "HCHANNEL";
#define CHECK_HGE {if(!hge){PyErr_SetString(PyExc_SystemError,"hge is NULL.");return 0;}}

#include "pyhgeCore_System.inl"
#include "pyhgeCore_Input.inl"
#include "pyhgeCore_Texture.inl"
#include "pyhgeCore_Target.inl"
#include "pyhgeCore_Gfx.inl"
#include "pyhgecore_Timer.inl"
#include "pyhgeCore_Random.inl"
#include "pyhgeCore_Effect.inl"
#include "pyhgeCore_Color.inl"
PyMethodDef hgeMethods[]={
	//color
	{"__set_color_rgba",py__set_color_rgba,py__set_color_rgba_flag,py__set_color_rgba_doc},
	{"__get_color_rgba",py__get_color_rgba,py__get_color_rgba_flag,py__get_color_rgba_doc},
	{"__set_color_hsva",py__set_color_hsva,py__set_color_hsva_flag,py__set_color_hsva_doc},
	{"__get_color_hsva",py__get_color_hsva,py__get_color_hsva_flag,py__get_color_hsva_doc},
	//system
	{"System_Initiate",	pySystem_Initiate,METH_NOARGS,"Initializes all hardware and software needed to run engine and creates application window."},
	{"System_Shutdown",	pySystem_Shutdown,METH_NOARGS,"Restores video mode, frees all allocated resources and destroys application window."},
	{"System_Start",	pySystem_Start,METH_NOARGS,"Starts running user defined frame function."},
	{"System_SetState",	pySystem_SetState,METH_VARARGS,"Sets internal system states."},
	{"System_GetState",	pySystem_GetState,METH_VARARGS,"Returns internal system state value."},
	{"System_GetErrorMessage",pySystem_GetErrorMessage,METH_NOARGS,"Returns last occured HGE error description."},
	{"System_Log",		pySystem_Log,METH_VARARGS,"Writes a formatted message to the log file."},
	{"System_Launch",	pySystem_Launch,METH_VARARGS,"Launches an URL or external executable/data file."},
	{"System_Snapshot",pySystem_Snapshot,METH_VARARGS,"Saves current screen snapshot into a file."},
	//input 
	{"Input_GetMousePos",pyInput_GetMousePos,METH_NOARGS,"Returns current mouse cursor position."},
	{"Input_SetMousePos",pyInput_SetMousePos,METH_VARARGS,"Sets current mouse cursor position."},
	{"Input_GetMouseWheel",pyInput_GetMouseWheel,METH_NOARGS,"Returns the mouse wheel shift since the previous call to frame function."},
	{"Input_IsMouseOver",pyInput_IsMouseOver,METH_NOARGS,"Tests if mouse cursor is inside HGE window or not."},
	{"Input_KeyDown",pyInput_KeyDown,METH_VARARGS,"Tests if a key was pressed down during the last frame."},
	{"Input_KeyUp",pyInput_KeyUp,METH_VARARGS,"Tests if a key was released during the last frame."},
	{"Input_GetKeyName",pyInput_GetKeyName,METH_VARARGS,"Returns a key or mouse button name from it's code."},
	{"Input_GetKeyState",pyInput_GetKeyState,METH_VARARGS,"Determines whether a key or mouse button is up or down at the time the function is called."},
	{"Input_GetKey",pyInput_GetKey,METH_NOARGS,"Returns the last key pressed since previous call to frame function."},
	{"Input_GetChar",pyInput_GetChar,METH_NOARGS,"Returns the last pressed character since previous call to frame function."},
	{"Input_GetEvent",pyInput_GetEvent,METH_NOARGS,"Gets the next input event from the queue."},
	//texture
	{"Texture_Create",pyTexture_Create,METH_VARARGS,"Creates an empty texture."},
	{"Texture_Load",pyTexture_Load,METH_VARARGS,"Loads a texture from memory, resource pack or disk file."},
	{"Texture_Free",pyTexture_Free,METH_VARARGS,"Deletes loaded or created texture and frees associated resources."},
	{"Texture_GetWidth",pyTexture_GetWidth,METH_VARARGS,"Returns a texture width in pixels."},
	{"Texture_GetHeight",pyTexture_GetHeight,METH_VARARGS,"Returns a texture height in pixels."},
	//target
	{"Target_Create",pyTarget_Create,METH_VARARGS,"Creates a render target."},
	{"Target_Free",pyTarget_Free,METH_VARARGS,"Deletes a render target and frees associated resources."},
	{"Target_GetTexture",pyTarget_GetTexture,METH_VARARGS,"Returns a render target's texture handle."},
	//gfx
	{"Gfx_BeginScene",pyGfx_BeginScene,METH_VARARGS,pyGfx_BeginScene_doc},
	{"Gfx_EndScene",pyGfx_EndScene,METH_NOARGS,pyGfx_EndScene_doc},
	{"Gfx_Clear",pyGfx_Clear,METH_VARARGS,pyGfx_Clear_doc},
	{"Gfx_RenderLine",pyGfx_RenderLine,METH_VARARGS,pyGfx_RenderLine_doc},
	{"Gfx_Render",pyGfx_Render,METH_VARARGS,pyGfx_Render_doc},
	{"Gfx_SetClipping",pyGfx_SetClipping,METH_VARARGS,pyGfx_SetClipping_doc},
	{"Gfx_SetTransform",pyGfx_SetTransform,METH_VARARGS,pyGfx_SetTransform_doc},
	//timer
	{"Timer_GetTime",pyTimer_GetTime,METH_NOARGS,pyTimer_GetTime_doc},
	{"Timer_GetDelta",pyTimer_GetDelta,METH_NOARGS,pyTimer_GetDelta_doc},
	{"Timer_GetFPS",pyTimer_GetFPS,METH_NOARGS,pyTimer_GetFPS_doc},
	//random
	{"Random_Seed",pyRandom_Seed,METH_VARARGS,pyRandom_Seed_doc},
	{"Random_Int",pyRandom_Int,METH_VARARGS,pyRandom_Int_doc},
	{"Random_Float",pyRandom_Float,METH_VARARGS,pyRandom_Float_doc},
	//effect
	{"Effect_Load",pyEffect_Load,METH_VARARGS,pyEffect_Load_doc},
	{"Effect_Free",pyEffect_Free,METH_VARARGS,pyEffect_Free_doc},
	{"Effect_Play",pyEffect_Play,METH_VARARGS,pyEffect_Play_doc},
	{"Effect_PlayEx",pyEffect_PlayEx,METH_VARARGS,pyEffect_PlayEx_doc},
	{NULL,NULL,0,NULL}
};
